import { initGlobalState, MicroAppStateActions } from 'qiankun';

// 初始化 state
const state = {
    test: 12346,
    msg: 'hello qiankun',
    isUnMountSubApp: false
}
const actions: MicroAppStateActions = initGlobalState(state);

actions.onGlobalStateChange((state, prev) => {
  // state: 变更后的状态; prev 变更前的状态
  console.log('main onGlobalStateChange', state, prev);
  if(state.isUnMountSubApp) {
    window.location.reload()
    actions.setGlobalState({isUnMountSubApp: false})
  }
});
actions.setGlobalState(state);
actions.offGlobalStateChange();